








using CKS2320.Domain.DBEntity;
using CKS2320.Repository;
using CKS2320.Repository.Interface;
using CKS2320.Service;
using CKS2320.Service.Interface;
using Microsoft.AspNetCore.Builder;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;

var builder = WebApplication.CreateBuilder(args);
// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddScoped<ICksLargeTotalService, CksLargeTotalService>();
builder.Services.AddScoped<ICksLargeTotalRepository, CksLargeTotalRepository>();
builder.Services.AddScoped<IShapeService, ShapeService>();
builder.Services.AddScoped<IShapeRepository, ShapeRepository>();
builder.Services.AddScoped<IVoltageWithstandService, VoltageWithstandService>();
builder.Services.AddScoped<IVoltageWithstandRepository, VoltageWithstandRepository>();
builder.Services.AddScoped<IThicknessDetectionService, ThicknessDetectionService>();
builder.Services.AddScoped<IThicknessDetectionRepository, ThicknessDetectionRepository>();
builder.Services.AddScoped<IEquipmentfailureService, EquipmentfailureService>();
builder.Services.AddScoped<IEquipmentfailureRepository, EquipmentfailureRepository>();
builder.Services.AddDbContext<DBContext>(options => options.
   UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
builder.Services.AddCors(options => options.AddPolicy("CorsPolicy", builder =>
{
    builder.AllowAnyMethod().AllowAnyHeader().SetIsOriginAllowed(o => true).AllowCredentials();
})); 
var MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
builder.Services.AddCors(options =>
{
    options.AddPolicy(MyAllowSpecificOrigins,
                          policy =>
                          {
                              policy.WithOrigins("http://example.com",
                                                  "http://www.contoso.com")
                                                  .AllowAnyHeader()
                                                  .AllowAnyMethod();
                          });
});
var app = builder.Build();

// Configure the HTTP request pipeline.
//if (app.Environment.IsDevelopment())
//{
    app.UseSwagger();
    app.UseSwaggerUI();
//}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();
app.UseCors("CorsPolicy"); 
app.UseCors(MyAllowSpecificOrigins);
app.Run();
